using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class TransferDetMap : EntityTypeConfiguration<TransferDet>
    {
        public TransferDetMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.ITEM)
                .HasMaxLength(10);

            this.Property(t => t.DESC)
                .HasMaxLength(50);

            this.Property(t => t.Vendor)
                .HasMaxLength(6);

            this.Property(t => t.Color)
                .HasMaxLength(20);

            this.Property(t => t.Size)
                .HasMaxLength(20);

            this.Property(t => t.Manufaccode)
                .HasMaxLength(20);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.Barcode)
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("TransferDet");
            this.Property(t => t.NUMBER).HasColumnName("NUMBER");
            this.Property(t => t.TRANSFER).HasColumnName("TRANSFER");
            this.Property(t => t.TRANSFERPW).HasColumnName("TRANSFERPW");
            this.Property(t => t.ONHAND).HasColumnName("ONHAND");
            this.Property(t => t.ONHANDPW).HasColumnName("ONHANDPW");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.Vendor).HasColumnName("Vendor");
            this.Property(t => t.Season).HasColumnName("Season");
            this.Property(t => t.Color).HasColumnName("Color");
            this.Property(t => t.Size).HasColumnName("Size");
            this.Property(t => t.Manufaccode).HasColumnName("Manufaccode");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.Barcode).HasColumnName("Barcode");
            this.Property(t => t.ExpiryDate).HasColumnName("ExpiryDate");
            this.Property(t => t.UOFMSALES).HasColumnName("UOFMSALES");

            // Relationships
            this.HasOptional(t => t.Item1)
                .WithMany(t => t.TransferDets)
                .HasForeignKey(d => d.ITEM);
            this.HasOptional(t => t.ItemType)
                .WithMany(t => t.TransferDets)
                .HasForeignKey(d => d.Type);
            this.HasOptional(t => t.ItmCateg)
                .WithMany(t => t.TransferDets)
                .HasForeignKey(d => d.Category);
            this.HasRequired(t => t.Transfer1)
                .WithMany(t => t.TransferDets)
                .HasForeignKey(d => d.NUMBER);
            this.HasOptional(t => t.Vend)
                .WithMany(t => t.TransferDets)
                .HasForeignKey(d => d.Vendor);

        }
    }
}
